package office.dao.person;

import java.util.Iterator;
import java.util.Map;

import platform.common.dao.impl.BaseDomainProviderImpl;


public class PersonLogDP extends BaseDomainProviderImpl {
	public String getLogByUidAndDate(){
		String hql = "from PersonLog where user.id =? and createDate between ? and ? order by createDate desc";
		return hql;
	}
	
	public String getLogByParams(Map<String,Object> condMap){
		StringBuffer strBuf = new StringBuffer();
		strBuf.append(" from "+ this.getDomainClassName() + " where 1=1 ");
		Iterator<String> it = condMap.keySet().iterator();
		while(it.hasNext()){
			String str = (String)it.next();
			if(str.equals("user.id")){
				strBuf.append(" and "+str+" = '"+condMap.get(str)+"' ");
			}
			if(str.equals("logDayStart")){
				strBuf.append(" and createDate between '"+condMap.get(str)+"'");
				strBuf.append(" and '"+condMap.get("logDayEnd")+"' ");
			}
			if(str.equals("createDate")){
				strBuf.append(" and ( "+str+" >= '"+condMap.get(str)+"'");
			}
		}
		strBuf.append(" order by createDate desc");
		return strBuf.toString();
	}
	
	public String getLogByUid(){
		String hql = "from PersonLog where uid =? order by createDate desc";
		return hql;
	}

	

}
